package com.itheima.day07.ZuoYe.Zuoye5;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        Card htcard3 = new Card("3","红桃",3);
        Card htcard4 = new Card("4","红桃",4);
        Card htcard5 = new Card("5","红桃",5);
        Card htcard6 = new Card("6","红桃",6);
        Card htcard7 = new Card("7","红桃",7);
        Card htcard8 = new Card("8","红桃",8);
        Card htcard9 = new Card("9","红桃",9);
        Card htcard10 = new Card("10","红桃",10);
        Card htcardj = new Card("J","红桃",11);
        Card htcardq = new Card("Q","红桃",12);
        Card htcardk = new Card("K","红桃",13);
        Card htcardA = new Card("A","红桃",14);
        Card htcard2 = new Card("2","红桃",15);
        Card btcard3 = new Card("3","黑桃",3);
        Card btcard4 = new Card("4","黑桃",4);
        Card btcard5 = new Card("5","黑桃",5);
        Card btcard6 = new Card("6","黑桃",6);
        Card btcard7 = new Card("7","黑桃",7);
        Card btcard8 = new Card("8","黑桃",8);
        Card btcard9 = new Card("9","黑桃",9);
        Card btcard10 = new Card("10","黑桃",10);
        Card btcardj = new Card("J","黑桃",11);
        Card btcardq = new Card("Q","黑桃",12);
        Card btcardk = new Card("K","黑桃",13);
        Card btcardA = new Card("A","黑桃",14);
        Card btcard2 = new Card("2","黑桃",15);
        Card fpcard3 = new Card("3","方片",3);
        Card fpcard4 = new Card("4","方片",4);
        Card fpcard5 = new Card("5","方片",5);
        Card fpcard6 = new Card("6","方片",6);
        Card fpcard7 = new Card("7","方片",7);
        Card fpcard8 = new Card("8","方片",8);
        Card fpcard9 = new Card("9","方片",9);
        Card fpcard10 = new Card("10","方片",10);
        Card fpcardj = new Card("J","方片",11);
        Card fpcardq = new Card("Q","方片",12);
        Card fpcardk = new Card("K","方片",13);
        Card fpcardA = new Card("A","方片",14);
        Card fpcard2 = new Card("2","方片",15);
        Card mhcard3 = new Card("3","梅花",3);
        Card mhcard4 = new Card("4","梅花",4);
        Card mhcard5 = new Card("5","梅花",5);
        Card mhcard6 = new Card("6","梅花",6);
        Card mhcard7 = new Card("7","梅花",7);
        Card mhcard8 = new Card("8","梅花",8);
        Card mhcard9 = new Card("9","梅花",9);
        Card mhcard10 = new Card("10","梅花",10);
        Card mhcardj = new Card("J","梅花",11);
        Card mhcardq = new Card("Q","梅花",12);
        Card mhcardk = new Card("K","梅花",13);
        Card mhcardA = new Card("A","梅花",14);
        Card mhcard2 = new Card("2","梅花",15);
        Card bigboss = new Card("大王","BIGBOSS",17);
        Card smallboss = new Card("小王","SMALLBOSS",16);
        List<Card> list = new ArrayList<>();
        list.add(mhcard2);list.add(mhcardA);list.add(mhcardk);list.add(mhcardq);list.add(mhcardj);
        list.add(mhcard10);list.add(mhcard9);list.add(mhcard8);list.add(mhcard7);list.add(mhcard6);
        list.add(mhcard5);list.add(mhcard4);list.add(mhcard3);list.add(fpcard2);list.add(fpcardA);
        list.add(fpcardk);list.add(fpcardq);list.add(fpcardj);list.add(fpcard10);list.add(fpcard9);list.add(fpcard8);
        list.add(fpcard7);list.add(fpcard6);list.add(fpcard5);list.add(fpcard4);list.add(fpcard3);list.add(btcard2);
        list.add(btcardA);list.add(btcardk);list.add(btcardq);list.add(btcardj);list.add(btcard10);list.add(btcard9);
        list.add(btcard8);list.add(btcard7);list.add(btcard6);list.add(btcard5);list.add(btcard4);list.add(btcard3);
        list.add(htcard2);list.add(htcardA);list.add(htcardk);list.add(htcardq);list.add(htcardj);list.add(htcard10);
        list.add(htcard9);list.add(htcard8);list.add(htcard7);list.add(htcard6);list.add(htcard5);list.add(htcard4);
        list.add(htcard3);list.add(bigboss);list.add(smallboss);
        List<Card> Player1 = new ArrayList<>();
        List<Card> Player2 = new ArrayList<>();
        List<Card> Player3 = new ArrayList<>();
        List<Card> dipai = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < 3; i++) {
            int index = random.nextInt(list.size());
            dipai.add(list.get(index));
            list.remove(index);

        }
        choupai(random, list, Player1);
        System.out.println("");
        System.out.println("----------------------");
        choupai(random, list, Player2);
        System.out.println("");
        System.out.println("----------------------");
        choupai(random, list, Player3);


    }

    private static void choupai(Random random, List<Card> list, List<Card> Player1) {
        for (int i = 0; i < 17; i++) {

            int index = random.nextInt(list.size());
            Player1.add(list.get(index));
            if(list.size()!=0){
                list.remove(index);
            }else{
                break;
            }
        }
        for (int i = 0; i < Player1.size()-1; i++) {
            for (int j = 0; j < Player1.size()-1-i; j++) {
                if(Player1.get(j).getSize()> Player1.get(j+1).getSize()){
                    Card temp = Player1.get(j);
                    Player1.set(j, Player1.get(j+1));
                    Player1.set(j+1,temp);
                }
            }
        }
        for (int i = 0; i < Player1.size(); i++) {
            System.out.print(Player1.get(i).getColor()+ Player1.get(i).getName());
        }
    }
}
